import axios from 'axios';

const uniAdapter = (config) => {
  return new Promise((resolve, reject) => {
    uni.request({
      url: config.url,
      method: config.method,
      data: config.data,
      header: config.headers,
      success: (res) => {
        resolve({
          data: res.data,
          status: res.statusCode,
          statusText: res.errMsg,
          headers: res.header,
          config: config,
          request: null
        });
      },
      fail: (err) => {
        reject(err);
      }
    });
  });
};

const instance = axios.create({
  baseURL: 'https://zcgjcy.com/api/',
  timeout: 10000,
  adapter: uniAdapter, 
});

export default instance;
